package com.bawei.mdm2207alast.report

import com.bawei.mdm2207alast.base.BaseViewModel
import com.bawei.mdm2207alast.base.IUiIntent
import com.bawei.mdm2207alast.model.RetrofitManager
import com.google.gson.Gson
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody

/**
 * 作者：赵亮
 * 时间：2024/12/19 11:20
 * 功能：
 */
class ReportViewModel : BaseViewModel() {
    override fun handIntent(it: IUiIntent) {
        when(it) {
            // 查询工作日志
            is ReportIntent.SelReport -> httpRequest(RetrofitManager.apiService.selReport(it.map))
            is ReportIntent.AddReport -> httpRequest(RetrofitManager.apiService.addReport(RequestBody.create("application/json".toMediaType(), Gson().toJson(it.map))))
        }
    }
}